package pcgen.android.widget;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Paint.Style;
import android.util.AttributeSet;
import android.widget.LinearLayout;

public class TransparentPanel extends LinearLayout 
{ 
	public TransparentPanel(Context context, AttributeSet attrs) 
	{
		super(context, attrs);
		init();
	}

	public TransparentPanel(Context context) 
	{
		super(context);
		init();
	}
	
	public void setInnerPaint(Paint innerPaint) 
	{
		_paintInner = innerPaint;
	}

	public void setBorderPaint(Paint borderPaint) 
	{
		_paintBorder = borderPaint;
	}

    @Override
    protected void dispatchDraw(Canvas canvas) 
    {
    	RectF drawRect = new RectF();
    	drawRect.set(0,0, getMeasuredWidth(), getMeasuredHeight());
    	
    	canvas.drawRoundRect(drawRect, 10, 10, _paintInner);
		canvas.drawRoundRect(drawRect, 10, 10, _paintBorder);
		
		super.dispatchDraw(canvas);
    }

	protected void init() 
	{
		Paint paint = new Paint();
		paint.setARGB(225, 75, 75, 75); //gray
		paint.setAntiAlias(true);
		setPaintInner(paint);

		paint = new Paint();
		paint.setARGB(255, 255, 255, 255);
		paint.setAntiAlias(true);
		paint.setStyle(Style.STROKE);
		paint.setStrokeWidth(2);
		setPaintBorder(paint);
	}
	
	protected void setPaintBorder(Paint paint)
	{
		_paintBorder = paint;
	}
	
	protected void setPaintInner(Paint paint)
	{
		_paintInner = paint;
	}
    
    private Paint _paintInner, _paintBorder;
}